package com.atguigu.controller;

import com.atguigu.domain.User;
import com.atguigu.service.UserService;
import com.atguigu.study.resp.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping(value = "/user/add")
    public ResultData<Boolean> addUser(@RequestBody User user)
    {
        return ResultData.success(userService.addUser(user));
    }

    //http://localhost:2404/user/226
    @GetMapping(value = "/user/{id}")
    public ResultData<User> getUserById(@PathVariable("id") Integer id)
    {
        return ResultData.success(userService.getUserById(id));
    }
}
